<template>
	<view><web-view ref="myWebView" :webview-styles="webviewStyles" :src="weburl"  @message="getmessage"></web-view></view>
</template>

<script>
export default {
	data() {
		return {
			webviewStyles: {
				progress: {
					color: '#FF3333'
				}
			},
			weburl: ''
		};
	},
	onLoad(fatherPage) {
		
		console.log(fatherPage);
		let str = JSON.stringify(fatherPage);
		if (str.indexOf('webUrl') >= 0) {
			console.log(fatherPage.webUrl);
			this.weburl = JSON.parse(fatherPage.webUrl);
			console.log(JSON.parse(fatherPage.webUrl));
		}else{
			this.weburl = uni.getStorageSync('webUrl');
		}
		console.log(this.weburl);
		//this.getUiStyle();
	},
	
	methods: {
		getUiStyle() {
			var style = plus.navigator.getUiStyle();
			if ('dark' == style) {
				//console.log('当前为暗黑模式');
				// //plus.nativeUI.alert('当前为暗黑模式');
				uni.setNavigationBarColor({
					frontColor: '#ffffff',
					backgroundColor: '#1F1F1F',
					animation: {
						duration: 400,
						timingFunc: 'easeIn'
					}
				});
				uni.setTabBarStyle({
					color: '#929191',
					selectedColor: '$base-color',
					backgroundColor: '#1F1F1F',
					borderStyle: 'black'
				});
			} else {
				//console.log('当前为普通模式');
				// //plus.nativeUI.alert('当前为普通模式');
				uni.setNavigationBarColor({
					frontColor: '#000000',
					backgroundColor: '#ffffff',
					animation: {
						duration: 400,
						timingFunc: 'easeIn'
					}
				});
				uni.setTabBarStyle({
					color: '#929191',
					selectedColor: '$base-color',
					backgroundColor: '#ffffff',
					borderStyle: 'black'
				});
			}
		},
		navBack() {
			//console.log(1111);
			uni.navigateBack();
		},
		getmessage(res){
		
			
			if(res.detail.data[0].button_type){
				if(res.detail.data[0].button_type == 'copy'){
					uni.setClipboardData({
						data: res.detail.data[0].data
					});
					this.$api.msg(
						'已复制到剪切板');
				}
			}
			
		},
	}
};

</script>

<style></style>
